---
layout : doc
title : Lifecycle and Tombstoning support
permalink: docs\Lifecycle.html
---

## Lifecycle

Phoenix supports both WP7 and WPF, and when designing it it seemed useful to keep some of the support and features in the WPF version to allow views in the back stack to be garbage collected, then restored at a later stage. 

### Lifecycle events

Each viewmodel can override the `OnActivated` and `OnDeactivated`, these methods allow the viewmodel to register subscriptions, refresh data, and restore state. If your viewmodel implements `IDisposable` it will be called when the view model can no longer be reactivated (navigate back from that view, application close, or if the hosting navigation frame is disposed).

### Saving transient state
Phoenix has a helper method `Transient(()=>MyProperty);` which marks that property as transient. This means when the viewmodel is deactivated, the state of that property will automatically be saved in the page state. When the application is restored from Tombstone, or that view is recreated because it was garbage collected, that state will be restored.

There is not much else to Phoenix's lifecycle.